package eu.goldenak.ircbot.module;

import eu.goldenak.ircbot.IrcBot;
import eu.goldenak.ircbot.BotGroup.DistributeMessage;

/**
 * This class implemented all methods from ModuleInterface. This way, you only
 * have to override methods you actually need when extending this class.
 */
public abstract class ModuleBase implements ModuleCallbacks {
        
        /**
         * Some useful formatting constants.
         */
        public enum Format {
                BOLD (2), COLOR (3), RESET (15), INVERT (22), ULINE (31);
                
                private final char cValue;
                private Format (int nChar) {
                        cValue = (char) nChar;
                }
                
                public String toString () {
                        return Character.toString (cValue);
                }
        }
        
        /**
         * The default colors as defined by mIRC.
         */
        public enum Color {
                WHITE (0), BLACK (1), NAVY (2), GREEN (3),
                RED (4), BROWN (5), PURPLE (6), ORANGE (7),
                YELLOW (8), LIME (9), TEAL (10), CYAN (11),
                BLUE (12), PINK (13), GREY (14), LTGREY (15);
                
                private final int m_nColor;
                
                private Color (int nColor) {
                        m_nColor = nColor;
                }
                
                public String toString () {
                        String sReturn = Integer.toString (m_nColor);
                        if (m_nColor < 10) {
                                sReturn = "0" + sReturn;
                        }
                        
                        return Format.COLOR + sReturn;
                }
        }
	
	/**
	 * Returns the current version of this module, as an integer, so no fancy
	 * stuff here. Return 0 to supply no version information.
	 */
	public int getVersion() {
		return 0;
	}
	
	/**
	 * Gets called after all modules have been processed. The returned array of
	 * messages will be evenly distributed over the connected bots.
	 */
	public DistributeMessage [] getDistributeMessages() {
		return null;
	}
	
	/**
	 * Someone changed his/her nickname. Note that this event doesn't supply
	 * the channel(s) it occurred in.
	 */
	public void onChangeNick (IrcBot pBot, String sOldNick, String sNewNick) {
		
	}
	
	/**
	 * The topic of a channel has been changed.
	 */
	public void onChangeTopic (IrcBot pBot, String sChannel, String sNickname, String sNewTopic) {
		
	}
	
	/**
	 * When joining a channel, you get sent a bit of info, including the topic.
	 * That gets handled in here.
	 */
	public void onChannelTopic (IrcBot pBot, String sChannel, String sTopic) {
		
	}
	
	/**
	 * When joining a channel, you also get a list with the names who are
	 * currently in the channel. Note that prefixes are in the names (~&@%+).
	 */
	public void onChannelNames (IrcBot pBot, String sChannel, String sNames) {
		
	}
	
	/**
	 * Someone joined a channel.
	 */
	public void onChannelJoin (IrcBot pBot, String sChannel, String sNickname) {
		
	}
	
	/**
	 * Someone was kicked from a channel by someone.
	 */
	public void onChannelKick (IrcBot pBot, String sChannel, String sKicked, String sKicker, String sReason) {
		
	}
	
	/**
	 * A mode has been set on a channel or on the bot itself.
	 */
	public void onChannelMode (IrcBot pBot, String sChannel, String sMode) {
		
	}
	
	/**
	 * Someone left the channel.
	 */
	public void onChannelPart (IrcBot pBot, String sChannel, String sNickname, String sMessage) {
		
	}
	
	/**
	 * A PRIVMSG event in a channel. For personal PRIVMSGs see onPrivmsg().
	 */
	public void onChannelPrivmsg (IrcBot pBot, String sChannel, String sNickname, String sMessage) {
		
	}
	
	/**
	 * This method gets called as soon as we are connected and logged in to the 
	 * IRC server.
	 */
	public void onConnect (IrcBot pBot) {
		
	}
	
	/**
	 * This method gets called when someone sends us a client-to-client protocol
	 * message (prefixed and suffixed by a 0x01 char).
	 */
	public void onCTCP (IrcBot pBot, String sChannel, String sNickname, String sType, String sMessage) {
		
	}
	
	/**
	 * As soon as we get an invitation to join a channel this method gets 
	 * called.
	 */
	public void onInvite (IrcBot pBot, String sInviter, String sInvitee, String sChannel) {
		
	}
	
	/**
	 * When we receive a notice, this callback will be executed.
	 */
	public void onNotice (IrcBot pBot, String sChannel, String sNickname, String sMessage) {
		
	}
	
	/**
	 * A personal PRIVMSG.
	 */
	public void onPrivmsg (IrcBot pBot, String sNickname, String sMessage) {
		
	}
	
	/**
	 * Someone quit from the IRC server. Note that this event doesn't have a 
	 * channel in it.
	 */
	public void onQuit (IrcBot pBot, String sNickname, String sMessage) {
		
	}
	
	/**
	 * This method will get called everytime a message is received. If you're 
	 * considering on using this, you're probably looking for 
	 * onUnhandledCommand().
	 */
	public void onRaw (IrcBot pBot, String sRaw) {
		
	}
	
	/**
	 * This method will be called after a message has been sent to the IRC
	 * server.
	 */
	public void onRawSend (IrcBot pBot, String sRaw) {
		
	}
	
	/**
	 * This method will be called when the bot shuts down. This because of the
	 * lack of destructors in Java.
	 */
	public void onShutdown (IrcBot pBot) {
		
	}
	
	/**
	 * This method will be called with every loop the main loop makes. Use this
	 * for polling stuff or something.
	 */
	public void onTick () {
		
	}
	
	/**
	 * This method will be called whenever a message with an unknown IRC event
	 * has been received. Use this when is no callback for the type of message
	 * you want to process.
	 */
	public void onUnhandledCommand (IrcBot pBot) {
		
	}
}